<template>
	<div class="drawer_box_son">
		<div class="back_btn">
			<el-button type="primary" circle :icon="Back" @click="back_btn" />
		</div>
		<!-- 罪犯 -->
		<div class="zf_box" v-if="types == '罪犯'" style="width: 97%">
			<div class="type_box_text">
				{{ data.exceptType }}
			</div>
			<el-tabs v-model="activeName" type="card" @tab-click="handleClickTab">
				<el-tab-pane :label="stateYc ? '上报' : bjchShow == 'bj' ? '编辑' : '处理'" name="sb"></el-tab-pane>
				<el-tab-pane label="记录" name="jl"></el-tab-pane>
			</el-tabs>
			<div class="list_box isTable" v-if="activeName == 'jl'">
				<el-table :data="ycqkList" fit highlight-current-row stripe height="380" style="width: 100%" border>
					<el-table-column prop="startDate" label="时间" align="center">
						<template #default="scope">
							<div>
								{{
                  scope.row.createDate.split("T")[0] +
                  " " +
                  scope.row.createDate.split("T")[1].split(":")[0] +
                  ":" +
                  scope.row.createDate.split("T")[1].split(":")[1]
                }}
							</div>
						</template>
					</el-table-column>

					<el-table-column prop="ld" label="异常描述" align="center">
						<template #default="scope">
							{{ scope.row.content }}
						</template>
					</el-table-column>
					<el-table-column prop="ld" label="处理情况" align="center">
						<template #default="scope">
							{{ scope.row.handleContent }}
						</template>
					</el-table-column>
					<el-table-column prop="ld" label="操作" width="200" align="center">
						<template #default="scope">
							<el-button size="small" type="primary" @click.stop="handleEdit(scope.$index, scope.row)">
								编辑
							</el-button>
							<el-button size="small" type="primary" @click.stop="handleEditcl(scope.$index, scope.row)">
								处理
							</el-button>

							<el-popconfirm title="确认删除嘛" @confirm.stop="handleDelete(scope.row)">
								<template #reference>
									<el-button size="small" type="danger"> 删除 </el-button>
								</template>
							</el-popconfirm>
						</template>
					</el-table-column>
				</el-table>
			</div>

			<!-- 上报 -->
			<div v-if="activeName == 'sb'">
				<!-- 新增 -->

				<div style="display: flex" v-if="stateYc">
					<div style="display: flex; margin-bottom: 10px">
						<div style="min-width: 67px" v-if="data.exceptType == '指挥中心例行研判'" class="flex_center_center">
							研判结果：
						</div>
						<!-- <el-select
              v-model="ycqkObj.reportState"
              size="large"
              style="width: 260px"
              placeholder=" "
            >
              <el-option
                v-for="item in optionsTypeCv"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              />
            </el-select> -->
						<el-radio-group v-model="ycqkObj.reportState" v-if="data.exceptType == '指挥中心例行研判'">
							<el-radio value="1" size="large">上报</el-radio>
							<el-radio value="2" size="large">通报</el-radio>
							<el-radio value="3" size="large">预警</el-radio>
							<el-radio value="4" size="large">汇总</el-radio>
						</el-radio-group>
					</div>
				</div>

				<div v-if="bjchShow != 'bj'" style="display: flex; justify-content: space-between">
					<!-- <div style="display: flex; margin-bottom: 10px" v-if="!stateYc">
            <div style="width: 67px" class="flex_center_center">类型:</div>
            <div>{{ ycqkObj.type }}</div>
    
          </div> -->
					<div style="display: flex; margin-bottom: 10px" v-if="!stateYc">
						<div style="width: 67px" class="flex_center_center">上报人:</div>
						<div>
							{{ ycqkObj.reportUserName }}
						</div>
					</div>
				</div>
				<div v-if="bjchShow != 'bj'" style="display: flex; margin-bottom: 10px">
					<div style="min-width: 70px" class="flex_center_center" v-if="data.exceptType == '指挥中心例行研判'">
						分析研判:
					</div>
					<div v-else style="min-width: 70px" class="flex_center_center">
						情况说明
					</div>
					<div v-if="!stateYc" style="height: 136px; display: flex; align-items: center">
						{{ ycqkObj.content }}
					</div>
					<el-input v-else :disabled="!stateYc" v-model="ycqkObj.content" :rows="6" type="textarea"
						placeholder="请输入" />
				</div>

				<!-- 处理 -->
				<div v-if="!stateYc">
					<el-divider content-position="left">
						{{ bjchShow == "bj" ? "编辑" : "处理" }}
					</el-divider>
					<!-- <div style="display: flex; margin-bottom: 10px">
            <div style="width: 67px" class="flex_center_center">处理人:</div>
            <el-select
            
              v-model="ycqkObj.handleUser"
              size="large"
              placeholder=" "
              style="width: 260px"
            >
              <el-option
                v-for="item in optionsSbr"
                :key="item.account"
                :label="item.name"
                :value="item.account"
              />
            </el-select>
          </div> -->
					<div style="display: flex; margin-bottom: 10px" v-if="bjchShow == 'cl'">
						<div style="width: 78px" class="flex_center_center">处理情况:</div>
						<el-input v-model="ycqkObj.handleContent" :rows="6" type="textarea" placeholder="处理结果" />
					</div>
					<div style="display: flex; margin-bottom: 10px" v-if="bjchShow == 'bj'">
						<div style="width: 78px" class="flex_center_center">情况:</div>
						<el-input v-model="ycqkObj.content" :rows="6" type="textarea" placeholder="情况说明" />
					</div>
				</div>
			</div>
		</div>
		<!-- 值班 -->
		<div class="zb_box" v-if="types == '值班'">
			<div v-if="data.date == '夜班'" style="display: flex">
				<div>
					<el-form ref="ruleFormRef" :model="formData" label-position="right" label-width="80px"
						class="dd-edit-box">
						<!-- <div v-for="item in classListCv" :key="item.id">
              <div style="margin-bottom: 10px; transform: translateX(10px)">
                {{ getlabel("夜班") }}
              </div>
              <el-form-item
                v-for="it in item.children"
                :key="it.id"
                :label="it.name"
                :prop="`${it.id}`"
              >
                <el-cascader
                  disabled
                  placeholder="请选择"
                  :show-all-levels="false"
                  v-model="formData[`${it.id}`]"
                  :props="defaultProps"
                  :options="policeList"
                  style="width: 220px"
                  filterable
                  :clearable="false"
                  :collapse-tags="true"
                >
                </el-cascader>
              </el-form-item>
            </div> -->
						<div>
							<div style="margin-bottom: 10px; transform: translateX(10px)">
								{{ getlabel("夜班") }}
							</div>
							<el-form-item label="领导">
								<el-input disabled v-model="input1" style="width: 240px" placeholder="" />
							</el-form-item>
							<el-form-item label="民警">
								<el-input disabled v-model="input2" style="width: 240px" placeholder=" " />
							</el-form-item>
						</div>

						<el-form-item label="罪犯人数">
							<el-input type="number" v-model="num" placeholder="" />
						</el-form-item>
					</el-form>
				</div>

				<div class="inco_box">
					<div class="text">交</div>
					<div class="inco">
						<img src="../assets/images/zx.png" alt="" />
					</div>
					<div class="text">接</div>
				</div>

				<div>
					<el-form ref="ruleFormRef" :model="formData" label-position="right" label-width="80px"
						class="dd-edit-box">
						<div v-for="item in classListCv" :key="item.id">
							<div style="margin-bottom: 10px; transform: translateX(10px)">
								{{ getlabel("白班") }}
							</div>
							<el-form-item v-for="it in item.children" :key="it.id" :label="it.name" :prop="`${it.id}`">
								<el-cascader placeholder="请选择" :show-all-levels="false" v-model="formData[`${it.id}`]"
									:props="defaultProps" :options="policeList" style="width: 220px" filterable
									:clearable="false" :collapse-tags="true">
								</el-cascader>
							</el-form-item>
						</div>
					</el-form>
				</div>
			</div>

			<div style="display: flex" v-else>
				<div>
					<el-form ref="ruleFormRef" :model="formData" label-position="right" label-width="80px"
						class="dd-edit-box">
						<div v-for="item in classList" :key="item.id">
							<div style="margin-bottom: 10px; transform: translateX(10px)">
								{{ getlabel("白班") }}
							</div>
							<el-form-item v-for="it in item.children" :key="it.id" :label="it.name" :prop="`${it.id}`">
								<el-cascader disabled placeholder="请选择" :show-all-levels="false"
									v-model="formData[`${it.id}`]" :props="defaultProps" :options="policeList"
									style="width: 220px" filterable :clearable="false" :collapse-tags="true">
								</el-cascader>
							</el-form-item>
						</div>
						<!-- <div>
              <div style="margin-bottom: 10px; transform: translateX(10px)">
                {{ getlabel("白班") }}
              </div>
              <el-form-item label="领导">
                <el-input
                  disabled
                  v-model="input3"
                  style="width: 240px"
                  placeholder=""
                />
              </el-form-item>
              <el-form-item label="民警">
                <el-input
                  disabled
                  v-model="input4"
                  style="width: 240px"
                  placeholder=" "
                />
              </el-form-item>
            </div> -->
						<el-form-item label="罪犯人数">
							<el-input type="number" v-model="num" placeholder="" />
						</el-form-item>
					</el-form>
				</div>

				<div class="inco_box">
					<div class="text">交</div>
					<div class="inco">
						<img src="../assets/images/zx.png" alt="" />
					</div>
					<div class="text">接</div>
				</div>

				<div>
					<el-form ref="ruleFormRef" :model="formData" label-position="right" label-width="80px"
						class="dd-edit-box">
						<div v-for="item in classListCv" :key="item.id">
							<div style="margin-bottom: 10px; transform: translateX(10px)">
								{{ getlabel("夜班") }}
							</div>
							<el-form-item v-for="it in item.children" :key="it.id" :label="it.name" :prop="`${it.id}`">
								<el-cascader placeholder="请选择" :show-all-levels="false" v-model="formData[`${it.id}`]"
									:props="defaultProps" :options="policeList" style="width: 220px" filterable
									:clearable="false" :collapse-tags="true">
								</el-cascader>
							</el-form-item>
						</div>
					</el-form>
				</div>
			</div>
		</div>

		<!-- 填报人 -->
		<div class="tb_box">
			<div v-if="types == '填报人'">
				<div style="display: flex; margin-bottom: 10px; margin-top: 10px">
					<div style="width: 110px" class="flex_center_center">填报人:</div>
					<el-select v-model="tbObj.reportUser" size="large" placeholder=" " style="width: 260px">
						<el-option v-for="item in optionsSbr" :key="item.account" :label="item.name"
							:value="item.name" />
					</el-select>
				</div>
			</div>
		</div>
		<!-- 罪犯交接 -->
		<!-- 工作交接 -->
		<div class="gzjj_box" v-if="types == '工作交接'">
			<el-form ref="ruleFormRef" :model="formDataJJB" label-position="right" label-width="140px"
				class="dd-edit-box">
				<div style="display: flex; width: 100%; justify-content: space-between">
					<el-form-item label="分析研判">
						<el-input style="width: 640px" :rows="2" type="textarea" v-model="formDataJJB.clsx" />
					</el-form-item>
				</div>

				<div style="display: flex; width: 100%; justify-content: space-between">
					<el-form-item label="研判结果">
						<el-input v-model="formDataJJB.gzyq" style="width: 640px" :rows="2" type="textarea" />
					</el-form-item>
				</div>

				<div style="display: flex; width: 100%; justify-content: space-between">
					<el-form-item label="汇总">
						<el-input v-model="formDataJJB.remark" style="width: 640px" :rows="2" type="textarea" />
					</el-form-item>
				</div>
			</el-form>
		</div>
		<div class="zfjj_box"></div>
		<div class="dialog-footer" v-if="types != '罪犯' && types != '工作情况' && types != '填报人'">
			<el-button type="primary" @click="saveYcClick(ruleFormRef)">
				保存
			</el-button>
		</div>
		<div class="dialog-footer" v-if="types == '罪犯' && activeName != 'jl'" style="bottom: -100px">
			<el-button type="primary" @click="ycsbSave"> 保存 </el-button>
		</div>
		<div class="dialog-footer" v-if="types == '工作情况' && activeNamegz == 'xz'" style="bottom: -30px">
			<el-button type="primary" @click="gzqkSave"> 保存 </el-button>
		</div>
		<div class="dialog-footer" v-if="types == '填报人'" style="bottom: 100px">
			<el-button type="primary" @click="tbClick"> 保存 </el-button>
		</div>
	</div>
</template>

<script setup>
	import {
		ElMessage
	} from "element-plus";
	import http from "@/utils/api";
	import {
		throttle
	} from "lodash";
	import {
		Search,
		Share,
		Upload,
		TakeawayBox,
		Refresh,
		Collection,
		Plus,
		Loading,
		FolderDelete,
		Back,
	} from "@element-plus/icons-vue";
	import {
		ref,
		watch,
		onMounted,
		onBeforeUnmount,
		reactive,
		onBeforeMount,
		nextTick,
		onUnmounted,
	} from "vue";
	import {
		defineProps,
		defineEmits,
		computed
	} from "vue";
	let activeName = ref("wcl");
	const props = defineProps({
		//类型
		types: {
			type: String,
			default: "",
		},
		//当前行数据
		data: {
			type: Object,
			default: {},
		},
		orgIds: {
			type: Number,
			default: 22,
		},
		//判断值班新增或者编辑
		jcNub: {
			type: Number,
			default: {},
		},
		// 所有警察
		listData: {
			type: Array,
			default: [],
		},
		// 当前登录账号
		account: {
			type: String,
			default: "",
		},
		// 工作交接数据对象
		ggjjObj: {
			type: Object,
			default: {},
		},
		//罪犯人数
		zfrs: {
			type: Number,
			default: 0,
		},
	});
	let policeList = ref([]);
	let dateSfm = ref("");
	let hour = ref("");
	let formDataJJB = ref({});
	let daydata = ref("");
	const gzqkList = ref([]);
	let tbObj = ref({});
	// 获取年月日 时
	const getFormattedDateTime = () => {
		const now = new Date();
		const year = now.getFullYear();
		const month = String(now.getMonth() + 1).padStart(2, "0");
		const day = String(now.getDate()).padStart(2, "0");
		const hours = String(now.getHours()).padStart(2, "0");
		const minutes = String(now.getMinutes()).padStart(2, "0");
		const seconds = String(now.getSeconds()).padStart(2, "0");
		dateSfm.value = `${hours}:${minutes}:${seconds}`;
		hour.value = String(now.getHours()).padStart(2, "0");
		daydata.value = `${year}-${month}-${day}`;

		return `${year}-${month}-${day} ${hour.value}`;
	};

	let formData = reactive({});
	const defaultProps = {
		children: "children",
		label: "name",
		value: "account",
		multiple: true,
		emitPath: false,
	};
	const optionsSbr = ref([]);
	const ycqkObj = ref({});
	const gzqkObj = ref({});
	const emit = defineEmits(["childEventSon"]);
	const back_btn = () => {
		emit("childEventSon", "false");
	};

	const value1 = ref("");
	const pickerChang = (row) => {
		console.log(row, "4545");
		gzqkObj.value.hksd = row[0] + "-" + row[1];
	};

	const getlabel = (is) => {
		getFormattedDateTime();
		if (props.data.date == "白班") {
			if (is == "白班") {
				return `白班 ${daydata.value} 09:10`;
			} else if (is == "夜班") {
				return `夜班 ${daydata.value} 16:30`;
			}
		} else {
			if (is == "白班") {
				return `白班 ${daydata.value} 09:10`;
			} else if (is == "夜班") {
				return `夜班 ${getPreviousDay(daydata.value)} 16:30`;
			}
		}
	};

	const getPreviousDay = (dateString) => {
		const date = new Date(dateString);
		date.setDate(date.getDate() - 1); // Subtract one day
		const year = date.getFullYear();
		const month = String(date.getMonth() + 1).padStart(2, "0"); // Months are zero-based
		const day = String(date.getDate()).padStart(2, "0");
		return `${year}-${month}-${day}`;
	};

	let classList = ref([]);
	let classListCv = ref([]);
	//获取班次
	const getClassList = async () => {
		let res = await http.znjw.ShiftSelect({
			type: "zhzx",
			pId: 0,
			orgId: props.orgIds,
			startDate: "",
			endDate: "",
			isLock: 0,
			zbType: "1",
		});
		if (res.code == 0) {
			classList.value = res.data[0].children;

			classList.value.forEach((item) => {
				if (item.children.length) {
					item.children.forEach((itz) => {
						itz["nameBc"] = item.name;
					});
				}
			});
			let arr = classList.value.filter((item) => item.name == props.data.date);
			let arrCv = classList.value.filter((item) => item.name != props.data.date);
			console.log(classList.value, " classList.value");
			// 白班
			classList.value = arr;
			classListCv.value = arrCv;
			console.log();

			getUserAll();
			getShiftDutySelectSon();
		}
	};

	let input1 = ref("");
	let input2 = ref("");

	const getShiftDutySelectSon = async () => {
		let oldclassList = ref([]);

		let obj = {
			page: 1,
			limit: 200,
			orgId: props.orgIds,
			dutyType: "zhzx",
			startDate: getTimeRanges().split("至")[0].split(" ")[0] + " " + "09:10:00",
			endDate: getTimeRanges().split("至")[1].split(" ")[1] + " " + "09:10:00",
		};
		let res = await http.znjw.ShiftDutySelect(obj);
		if (res && res.code == 0) {
			console.log(res.data.data, " res.data.data");

			res.data.data.length &&
				res.data.data.forEach((item) => {
					item.zdbItem.length &&
						item.zdbItem.forEach((itz) => {
							if (itz.pshiftName == "夜班") {
								if (itz.shiftName == "领导") {
									input1.value = itz.zbry;
								}
								if (itz.shiftName == "民警") {
									input2.value = itz.zbry;
								}
								oldclassList.value.push(itz);
							}
						});
				});
		}
	};

	const getTimeRanges = () => {
		const now = new Date();

		// 获取今天的日期和时间
		const today = new Date(
			now.getFullYear(),
			now.getMonth(),
			now.getDate(),
			9,
			10,
			0,
			0
		);

		// 获取昨天的日期和时间
		const yesterday = new Date(today);
		yesterday.setDate(today.getDate() - 1);

		// 格式化日期为字符串
		const startDateTime = yesterday.toISOString().slice(0, 19).replace("T", " ");
		const endDateTime = today.toISOString().slice(0, 19).replace("T", " ");

		// 返回时间范围字符串
		return `${startDateTime} 至 ${endDateTime}`;
	};

	//获取值班弹窗人员
	const getUserAll = async () => {
		let res = await http.base.UserCascader({
			orgId: props.orgIds,
			typeId: "mj,fj",
			type: "",
		});
		if (res.code == 0) {
			policeList.value = res.data;
			props.listData.forEach((item) => {
				formData[item.shift] = item?.zbryAccount && item.zbryAccount.split(",");
			});
		}
	};

	let ycqkList = ref([]);
	//异常情况数据
	const getExceptionReportSelect = async (is = "0") => {
		let obj = {
			page: 1,
			limit: 99,
			orgId: props.orgIds,
			exceptType: "",
			startDate: "",
			endDate: "",
			state: "0,1",
			reportState: "1,0,2,3,4",
			reportType: "zhzx",
		};
		let res = await http.znjw.ExceptionReportSelect(obj);
		if (!res) return;
		if (res.code == 0) {
			ycqkList.value = res.data.data.filter(
				(item) => item.exceptType == props.data.exceptType
			);
		}
	};

	//工作情况数据

	const getWorkReportSelect = async (is = "0,1") => {
		let obj = {
			page: 1,
			limit: 99,
			orgId: props.orgIds,
			exceptType: "",
			startDate: "",
			endDate: "",
			state: is,
		};
		let res = await http.znjw.WorkReportSelect(obj);
		if (!res) return;
		if (res.code == 0) {
			gzqkList.value = res.data.data.filter(
				(item) => item.type == props.data.type
			);
		}
	};

	let stateYc = ref(true);
	const ycTableClick = (row) => {
		ycqkObj.value = row;
		activeName.value = "sb";
		stateYc.value = false;
	};
	const getPeople = () => {
		optionsSbr.value = [];
		props.listData.forEach((item) => {
			if (item.zbry.split(",").length <= 1) {
				optionsSbr.value.push({
					name: item.zbry,
					account: item.zbryAccount,
				});
			}
		});
		props.listData.forEach((item) => {
			if (item.zbry.split(",").length > 1) {
				item.zbryInfoArr.forEach((itz) => {
					optionsSbr.value.push({
						name: itz.name,
						account: itz.zbryAccount,
					});
				});
			}
		});
	};
	let num = ref(0);
	watch(
		() => props.types,
		(newValue, oldValue) => {
			if (props.types == "值班") {
				num.value = props.zfrs || 0;
				getClassList();
			}
			if (props.types == "罪犯") {
				ycqkObj.value.reportState = "1";

				if (props.data.exceptType) {
					activeName.value = "sb";
					ycqkObj.value.exceptType = props.data.exceptType;
				}
				if (props.data.type) {
					activeName.value = "sb";
					ycqkObj.value.exceptType = props.data.type;
				}

				getExceptionReportSelect();
				getPeople();
			}

			if (props.types == "工作情况") {
				getPeople();
			}
			if (props.types == "填报人") {
				getPeople();
			}
			if (props.types == "工作交接") {
				let obj = {};

				if (props.ggjjObj?.id) {
					obj["clsx"] = props.ggjjObj?.clsx || "";
					obj["remark"] = props.ggjjObj?.remark || "";
					obj["gzyq"] = props.ggjjObj?.gzyq || "";

					obj["jnrs"] = props.ggjjObj?.jnrs || 0;
					obj["jwrs"] = props.ggjjObj?.jwrs || 0;
					obj["cjrs"] = props.ggjjObj?.cjrs || 0;
					obj["zyrs"] = props.ggjjObj?.zyrs || 0;
					obj["qyrs"] = props.ggjjObj?.qyrs || 0;

					obj["id"] = props.ggjjObj?.id;
					formDataJJB.value = Object.assign(obj, {});
				}
			}
		}, {
			deep: true, // 深度监听
			immediate: true, // 立即触发回调
		}
	);

	const saveYcClick = () => {
		if (props.types == "罪犯") {
			ycsbSave();
		}
		if (props.types == "值班") {
			handleClickFd();
			// zbSave();
		}

		if (props.types == "工作交接") {
			emit("childEventSon", formDataJJB.value);
		}
	};
	const handleClickFd = throttle(() => {
		zbSave();
	}, 2000); // 1秒的防抖时间
	const zbSave = async () => {
		getFormattedDateTime();
		let jsonArr = [];
		let objs = JSON.parse(JSON.stringify(formData));
		Object.entries(objs).forEach(([key, value]) => {
			let item = {
				shift: key,
				zbry: formData[key].join(","),
			};
			jsonArr.push(item);
		});

		let obj = {
			date: daydata.value,
			zbType: 1, //1:值班，2:带班，3:备勤
			type: "zhzx",
			orgId: props.orgIds,
			json: JSON.stringify(jsonArr),
		};
		let res;

		if (props.jcNub) {
			res = await http.base.ZdbUpdate(obj);
		} else {
			res = await http.base.ZdbAdd(obj);
		}

		if (res.code == 0) {
			ElMessage({
				message: "保存成功",
				type: "success",
				plain: true,
			});
			let dateObj = {
				data: JSON.parse(sessionStorage.getItem("formDataJJB")),
				type: props.data.date,
				num: num.value,
				isBs: "值班",
			};

			if (props.data.date == "夜班") {
				emit("childEventSon", dateObj);
				// emit("childEventSon", JSON.parse(sessionStorage.getItem("formDataJJB")));
			} else {
				emit("childEventSon", dateObj);
			}
		}
	};

	//填报人提交
	const tbClick = () => {
		// return
		emit("childEventSon", tbObj);
	};

	//异常上报提交
	const ycsbSave = async () => {
		getFormattedDateTime();
		if (bjchShow.value == "bj") {
			let res;
			if (ycqkObj.value.id) {
				let obj = ycqkObj.value;
				res = await http.base.ExceptionReportUpdate(obj);
			}
			if (res.code == 0) {
				ElMessage({
					message: "保存成功",
					type: "success",
					plain: true,
				});
				ycqkObj.value = {};
				emit("childEventSon", "罪犯");
			}
			return;
		}
		if (activeName.value == "sb" && bjchShow.value != "bj") {
			let obj = {
				orgId: props.orgIds,
				state: 0,

				// file: "",
			};
			// if (!ycqkObj.value.content || !ycqkObj.value.reportUser) {
			//   ElMessage({
			//     type: "error",
			//     message: "请完善异常信息",
			//   });
			//   return;
			// }
			let res;
			if (ycqkObj.value.handleContent) {
				(obj["handleContent"] = ycqkObj.value.handleContent || ""),
				(obj["handleDate"] = new Date().toLocaleString().replace(/\//g, "-")),
				(obj["handleUser"] = props.account || ""),
				(obj["state"] = 1),
				(obj["id"] = ycqkObj.value.id),
				(res = await http.base.ExceptionReportUpdate(obj));
			} else {
				(obj["reportType"] = "zhzx"),
				(obj["content"] = ycqkObj.value.content || ""),
				(obj["reportUser"] = props.account || ""),
				(obj["exceptType"] = props.data.exceptType || ""),
				(obj["reportState"] = ycqkObj.value.reportState || "1"),
				(obj["reportDate"] =
					ycqkObj.value.reportDate || daydata.value || dateSfm.value);
				// obj["reportDate"] =
				//   ycqkObj.value.reportDate ||
				//   new Date().toLocaleString().replace(/\//g, "-")

				res = await http.base.ExceptionReportAdd(obj);
			}
			if (res.code == 0) {
				ElMessage({
					message: "上传成功",
					type: "success",
					plain: true,
				});
				ycqkObj.value = {};
				emit("childEventSon", "罪犯");
			}
		}
	};
	let bjchShow = ref("");
	//工作情况编辑
	const gzqkhandleEdit = (index, row) => {
		gzqkObj.value = row;
		activeNamegz.value = "xz";
	};

	const handleEditcl = (index, row) => {
		ycqkObj.value = row;
		activeName.value = "sb";
		stateYc.value = false;
		bjchShow.value = "cl";
	};

	const handleEdit = (index, row) => {
		let obj = {};
		if (row.state == 0) {
			obj = {
				id: row.id,
				type: row.type,
				reportUser: row.reportUser,
				content: row.content,

				handleContent: row.handleContent,
			};
		}
		if (row.state == 1) {
			obj = {
				id: row.id,
				type: row.type,
				handleUser: row.handleUser,
				handleContent: row.handleContent,
			};
		}
		activeName.value = "sb";
		stateYc.value = false;
		bjchShow.value = "bj";
		ycqkObj.value = Object.assign(obj, {});

		// ycqkObj.value = row;
	};
	let indexs = ref(0);
	const handleDelete = async (row) => {
		console.log(row, "row");
		let res = await http.znjw.ExceptionReportDel({
			id: row.id,
		});
		if (res && res.code == 0) {
			ElMessage({
				message: "删除成功",
				type: "success",
				plain: true,
			});
			getExceptionReportSelect(indexs.value - 1);
		}
	};
	const gzqkhandleDelete = async (row) => {
		console.log(row, "row");
		let res = await http.znjw.WorkReportDel({
			id: row.id,
		});
		if (res && res.code == 0) {
			ElMessage({
				message: "删除成功",
				type: "success",
				plain: true,
			});
			getWorkReportSelect();
		}
	};
	const handleClickTab = (tab) => {
		if (tab.index == 0) {
			bjchShow.value = "";
		}
		if (tab.index == 1 || tab.index == 0) {
			stateYc.value = true;
			ycqkObj.value = {};
		}
		indexs.value = tab.index;
		getExceptionReportSelect(tab.index - 1);
	};

	const activeNamegz = ref("xz");

	// 工作情况保存
	const gzqkSave = async () => {
		getFormattedDateTime();
		let res;
		if (gzqkObj.value?.id) {
			let obj = {};
			for (let key in gzqkObj.value) {
				if (gzqkObj.value[key]) {
					obj[key] = gzqkObj.value[key];
				}
			}
			delete obj.createDate;
			delete obj.createId;
			delete obj.orgName;
			delete obj.orgId;
			delete obj.reportDate;
			res = await http.znjw.WorkReportUpdate(obj);
		} else {
			let obj = Object.assign(gzqkObj.value, {});
			obj.orgId = props.orgIds;
			obj.type = props.data.type;
			obj.state = "0";
			obj.reportDate = daydata.value + " " + dateSfm.value;

			res = await http.znjw.WorkReportAdd(obj);
		}

		if (res && res.code == 0) {
			if (res.code == 0) {
				ElMessage({
					message: "保存成功",
					type: "success",
					plain: true,
				});
				emit("childEventSon", "工作情况");
			}
		}
	};
</script>

<style scoped lang="scss">
	::v-deep .el-tag.el-tag--info {
		background: #ff000000;
		color: white;
	}

	::v-deep .el-input.is-disabled .el-input__wrapper {
		background: #ffffff0d;
		box-shadow: none;
	}

	::v-deep .el-input__wrapper {
		background: #ffffff0d;
		box-shadow: none;
		color: white;
	}

	::v-deep .el-input__inner {
		color: white;
	}

	::v-deep .el-textarea__inner {
		background: #ffffff0d;
		box-shadow: none;
		color: white;
	}

	::v-deep .el-radio.el-radio--large .el-radio__label {
		color: white;
	}

	::v-deep .el-form-item__label {
		color: white !important;
	}

	::v-deep .isTable {
		.el-table .el-table__cell {
			padding: 0px 0px !important;
		}
	}

	.tb_box {
		transform: translateY(50px);
	}

	.type_box_text {
		position: absolute;
		top: -44px;
		font-weight: bold;
		font-size: 16px;
		left: 30px;
	}

	::v-deep .list_box .el-table {
		.cell {
			height: 30px;
			text-align: center;
			// border: 1px solid #ccc;

			font-size: 12px;
			// line-height: 38px;
		}
	}

	.inco_box {
		height: 180px;
		width: 200px;
		display: flex;
		align-items: center;
		justify-content: center;

		.text {
			font-size: 16px;
		}

		.inco {
			width: 50%;
			height: 60px;

			img {
				width: 100%;
				height: 80px;
				transform: translateY(-10px);
			}
		}
	}

	.type_box {
		font-size: 16px;
		font-weight: bold;
		margin-bottom: 20px;
		top: -45px;
		position: absolute;
		left: 31px;
	}

	.gzjj_box,
	.zf_box,
	.zb_box,
	.jj_box {
		position: absolute;
		left: 26px;
		top: 50px;
		color: white;

		.list_box {
			width: 100%;
			height: 300px;
		}
	}

	.drawer_box_son {
		width: 100%;
		height: 400px;
		position: relative;

		.back_btn {
			position: absolute;
			left: 16px;
			top: 0px;
		}

		.dialog-footer {
			position: absolute;
			bottom: -80px;
			right: 30px;
			// font-size: 18px;
		}
	}
</style>